﻿using SharpErp.Data.Common.Exceptions;
using System;
using System.Windows;
using System.Windows.Forms;

namespace SharpErp.UI.Common
{
    public class BaseTabForm : DevComponents.DotNetBar.OfficeForm
    {
    	protected SharpErp.Data.Service.ISharpErpService Service{get{return SharpErp.Service.Client.ServiceWarpper.GetService();}}

        protected event EventHandler BeforeLoad;

        protected event EventHandler AfterLoad;


        public string UniqueName()
        {
            return TitleText;
        }

        protected override void OnLoad(EventArgs e)
        {
            try
            {
            	if(BeforeLoad != null) BeforeLoad.Invoke(this, e);
            }
            catch (Exception ex)
            {
                SharpErp.Common.Util.Logger.GetLog().Error("BaseTabForm.BeforeLoad", ex);
            }
            base.OnLoad(e);
            try
            {
            	if(AfterLoad != null)AfterLoad.Invoke(this, e);
            }catch(ConnectFailedException ex)
            {
                SharpErp.Common.Util.Logger.GetLog().Error("init menu error:", ex);
                System.Windows.Forms.MessageBox.Show("服务器连接失败！", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                SharpErp.Common.Util.Logger.GetLog().Error("BaseTabForm.AfterLoad", ex);
            }

        }

      
    }
}
